<table id="jdDetailInfo_data"></table>
<script>		
	$(function(){
		$.post("../jdDetailInfoServletBack?t="+new Date(),{op:"getAllJdName"},function(data){
			var sltObj=$("#jd_jname");
			var opt;
			sltObj.empty(); //先清空数据
			$.each(data.jdNameInfo,function(index,item){
				opt="<option value='"+item.jbid+"'>"+item.jname+"</option>";
				sltObj.append($(opt));
			});
			
			datagrid=$('#jdDetailInfo_data').datagrid({   
			    url:'../jdDetailInfoServletBack',
			    queryParams:{op:"getJdDetailInfo"}, 
			    loadMsg:'努力加载数据中...',
			    fitColumns:true,
			    fit:true,
			    striped:true,
			    nowrap:false,
			    pagination:true,
			    pagePosition:'both',
			    rownumbers:true,
			    sortName:'jdid',
			    sortOrder:'asc',
			    remoteSort:false,
			    pageNumber:1,
			    pageSize:10,
			   	pageList:[10,20,30,40,50],
			    columns:[[   
					{field:'flag',title:'',checkbox:true,width:100,align:'center'},   
					{field:'jdid',title:'编号',width:100,align:'center',sortable:true},   
					{field:'temp',title:'景点名',width:150,align:'center',sortable:true}, 
					{field:'levelss',title:'等级',width:100,align:'center',sortable:true},    
					{field:'addr',title:'景点地址  ',width:200,align:'center',sortable:true},   
					{field:'edate',title:'开放时间',width:100,align:'center',sortable:true},   
					{field:'sdate',title:'关闭时间',width:100,align:'center',sortable:true},   
					{field:'_operate',title:'操作',width:100,align:'center',formatter:function(value,rowData,index){
						return "<a class='icon-file icon-padding' href=\"javascript:showDetails('"+rowData+"')\">编辑</a>"}
					}
			    ]],
			    toolbar: [{
			    	text:'添加',
					iconCls: 'icon-add',
					handler: function(){
						$("#jdDetailInfo_data_add").dialog("open");
					}
				},'-',{
			    	text:'删除',
					iconCls: 'icon-remove',
					handler: function(){
						var rows=$('#jdDetailInfo_data').datagrid("getChecked")[0];
						if(rows==undefined){
							$.messager.show({title:'温馨提示',msg:'请选择要删除的数据...',timeout:3000,showType:'slide'});
						}else{
							$.messager.confirm('信息确认', '您确定要删除选中的记录吗?', function(r){
								if (r){
									var jdids="";
									var st=datagrid.datagrid("getSelections").length;
									
									for(var j=0;j<st-1;j++){
										jdids+=datagrid.datagrid("getSelections")[j].jdid+",";
									}
									jdids+=datagrid.datagrid("getSelections")[j].jdid;

									$.post("../jdDetailInfoServletBack?t="+new Date(),{op:"delJdDetailInfo",jdids:jdids},function(data){
										data=parseInt($.trim(data));
										if(data>0){
											$.messager.show({title:'成功提示',msg:'信息删除成功...',timeout:3000,showType:'slide'});
											$('#jdDetailInfo_data').datagrid("reload");
										}else{
											$.messager.alert('失败提示','信息删除失败，请稍后重试...','error');
										}
									});
								}
										
							});
						}
					}
				}]
			}); 
		
			$('#jdDetailInfo_data').datagrid('getPager').pagination({
				beforePageText:'第',
				afterPageText:'页 共{pages}页',
				displayMsg:'当前显示{from}-{to} 条记录 共{total} 条记录'
			});
					
	 },"json");
		
}); 
</script>

<div id="jdDetailInfo_data_add" class="easyui-dialog" title="添加详细信息" style="width:1050px;height:500px"
	data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true,collapsible:true">
 	<br /><br />
 		<form action="" id="myfrom" style="padding-left:20px;float:left">
			<label>景点名称:</label><select id="jd_jname" name="jbid" style="width:200px"></select><br /><br /><br />
			<label style="vertical-align: top">景点等级:</label>
			<select id="jd_level" name="level" style="width:100px;">  
			    <option value="">请选择</option>  
			    <option value="3A">3A</option>  
			    <option value="4A">4A</option>  
			    <option value="5A">5A</option>  
			</select> <br /><br /><br />
			<label style="vertical-align: top">景点地址:</label><textarea id="jd_addr" name="addr" rows="3" cols="70" /></textarea><br /><br /><br />	
			<label>开放时间:</label><input  id="jd_edate" name="edate" class="easyui-timespinner" data-options="required:true,showSeconds:false" style="width:200px" /><br /><br /><br />
			<label>关闭时间:</label><input  id="jd_sdate" name="sdate" class="easyui-timespinner" data-options="required:true,showSeconds:false" style="width:200px" /><br /><br /><br />
			<label>景点图片:</label><input  id="jd_pic" name="pic" type="file" multiple="multiple" onchange="previewMultipleImage(this,'jd_show_pic')" /><br /><br />
			<label style="vertical-align: top">景点简介:</label><textarea id="jd_intro" name="intro" rows="10" cols="80" /></textarea><br /><br /><br />
			<a href="javascript:addDetailInfo()" class="easyui-linkbutton" data-options="iconCls:'icon-add'">添加</a>
 		</form>
 		<div id="jd_show_pic" style="float:right; width:300px; height:500px; border:1px solid #EF6819;margin:0px 20px"></div>
</div>  

<div id="jdDetailInfo_data_update" class="easyui-dialog" title="详细信息" style="width:600px;height:450px"
	data-options="iconCls:'icon-edit',resizable:true,modal:true,closed:true,collapsible:true">
 	<br />
 		<form action="" style="padding-left:30px;float:left">
 			<label>编　　号:</label><input id="jd_jdid_edit" name="jdid" style="width:100px" readOnly="readonly" /><br /><br /><br />
			<label>景点名称:</label><input id="jd_jname_edit" name="jbid" style="width:200px" readOnly="readonly" /><br /><br /><br />
			<label style="vertical-align: top">景点等级:</label>
			<select id="jd_level_edit" name="level" style="width:100px;">  
			    <option value="">请选择</option>  
			    <option value="3A">3A</option>  
			    <option value="4A">4A</option>  
			    <option value="5A">5A</option>  
			</select> <br /><br /><br />
			<label style="vertical-align: top">景点地址:</label><textarea id="jd_addr_edit" name="addr" rows="3" cols="70" /></textarea><br /><br /><br />	
			<label>开放时间:</label><input  id="jd_edate_edit" name="edate" class="easyui-timespinner" data-options="required:true,showSeconds:false" style="width:200px" /><br /><br /><br />
			<label>关闭时间:</label><input  id="jd_sdate_edit" name="sdate" class="easyui-timespinner" data-options="required:true,showSeconds:false" style="width:200px" /><br /><br /><br />			
			&nbsp;&nbsp;&nbsp;<a href="javascript:updateDetailInfo()" class="easyui-linkbutton" data-options="iconCls:'icon-edit'">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<a href="javascript:closeDetailInfo()" class="easyui-linkbutton" data-options="iconCls:'icon-no'">关闭</a>
			
 		</form>
</div> 

<script type="text/javascript">
	function addDetailInfo(){
		var jbid=$("#jd_jname").val();
		var level=$("#jd_level").val();
		var addr=$("#jd_addr").val();
		var edate=$("#jd_edate").val();
		var sdate=$("#jd_sdate").val();
		var intro=$("#jd_intro").val();	
		//发送请求
		$.ajaxFileUpload({
			url:"../jdDetailInfoServletBack?op=addDetailInfo",
			secureuri:false,
			fileElementId:"jd_pic",
			dataType:"json",
			data:{"jbid":jbid,"level":level,"addr":addr,"edate":edate,"sdate":sdate,"intro":intro},
			success:function(data,status){
				if(parseInt($.trim(data))>0){
					$.messager.show({title:'成功提示',msg:'详细信息添加成功...',timeout:3000,showType:'slide'});
					$("#jdDetailInfo_data_add").dialog("close");
					$("#jdDetailInfo_data").datagrid("reload");
					$("#myfrom").form("clear");  //清空from表单数据
					ue.setContent("");
				}else{
					$.messager.alert('失败提示','详细信息添加失败,请稍后再试...','error');
				}
			}
		});
		
		
	}
	
	
	function showDetails(){
		$("#jdDetailInfo_data_update").dialog("open");
		var rowData = datagrid.datagrid('getSelected');
		$("#jd_jdid_edit").val(rowData.jdid);
		$("#jd_jname_edit").val(rowData.temp);
		$("#jd_level_edit").val(rowData.levelss);
		$("#jd_addr_edit").val(rowData.addr);
		$("#jd_edate_edit").val(rowData.edate);
		$("#jd_sdate_edit").val(rowData.sdate);		
	}
	
	function updateDetailInfo(){
		var jdid=$("#jd_jdid_edit").val();
		var level=$("#jd_level_edit").val();
		var addr=$("#jd_addr_edit").val();
		var edate=$("#jd_edate_edit").val();
		var sdate=$("#jd_sdate_edit").val();
		
		$.post("../jdDetailInfoServletBack?t="+new Date(),{op:"updateJdDeatilInfo",jdid:jdid,level:level,addr:addr,edate:edate,sdate:sdate},function(data){
			data=parseInt($.trim(data));
			if(data>0){
				$.messager.show({title:'成功提示',msg:'信息更新成功...',timeout:3000,showType:'slide'});
				$("#jdDetailInfo_data_update").dialog("close");
				$("#jdDetailInfo_data").datagrid("reload");
			}else{
				$.messager.alert('失败提示','信息更新失败，请稍后重试...','error');
			}
		});
	}
	
	function closeDetailInfo(){
		$("#jdDetailInfo_data_update").dialog("close");
		$("#jdDetailInfo_data").datagrid("reload");
	}
	
		
	
	
</script>


